<!DOCTYPE HTML>
<html  lang="zh" xmlns:th="http://www.thymeleaf.org">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="white-bg">
    <div class="wrapper wrapper-content animated fadeInRight ibox-content">
        <form class="form-horizontal m" id="form-wMachine-edit" th:object="${wMachine}">
            <input id="machineId" name="machineId" th:field="*{machineId}"  type="hidden">

			<div class="form-group">	
				<label class="col-sm-3 control-label">品牌：</label>
				<div class="col-sm-8">
					<input id="brand" name="brand" th:field="*{brand}" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">设备名称：</label>
				<div class="col-sm-8">
					<input id="name" name="name" th:field="*{name}" class="form-control" type="text">
				</div>
			</div>
			<!--<div class="form-group">
				<label class="col-sm-3 control-label">服务类型ID：</label>
				<div class="col-sm-8">
					<input id="typeId" name="typeId" th:field="*{typeId}" class="form-control" type="text">
				</div>
			</div>-->
			<div class="form-group">
				<label class="col-sm-3 control-label">服务类型：</label>
				<div class="col-sm-8">
					<select data-placeholder="选择服务类型" name="typeId" id="typeId"
							class="form-control chosen-select" tabindex="2"
							style="width: 100%">
						<option th:if="${type!=null}" th:value="${type.typeId}" th:text="${type.name}">选择服务类型名称</option>
						<option th:value="${type.typeId}" th:each="type:${typeList}" th:text="${type.name}">选择服务类型门店</option>
					</select>
				</div>
			</div>

			<div class="form-group">
				<label class="col-sm-3 control-label">供应商：</label>
				<div class="col-sm-8">
					<select data-placeholder="选择供应商" name="vendorId" id="vendorId"
							class="form-control chosen-select" tabindex="2"
							style="width: 100%">
						<option th:if="${vendor!=null}" th:value="${vendor.vendorId}" th:text="${vendor.vendorName}">选择供应商名称</option>
						<option th:value="${vendor.vendorId}" th:each="vendor:${vendorList}" th:text="${vendor.vendorName}">选择供应商</option>
					</select>
				</div>
			</div>

			<div class="form-group">
				<label class="col-sm-3 control-label">店铺：</label>
				<div class="col-sm-8">
					<select data-placeholder="选择店铺" name="shopId" id="shopId"
							class="form-control chosen-select" tabindex="2"
							style="width: 100%">
						<option th:if="${shop!=null}" th:value="${shop.shopId}" th:text="${shop.shopName}">选择店铺名称</option>
						<option th:value="${shop.shopId}" th:each="shop:${shopList}" th:text="${shop.shopName}">选择放置门店</option>
					</select>
				</div>
			</div>

			<div class="form-group">	
				<label class="col-sm-3 control-label">产品描述：</label>
				<div class="col-sm-8">
					<input id="productDesc" name="productDesc" th:field="*{productDesc}" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">图片：</label>
				<div class="col-sm-8">
					<input id="imgId" name="imgId" th:field="*{imgId}" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">型号：</label>
				<div class="col-sm-8">
					<input id="model" name="model" th:field="*{model}" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">SN：</label>
				<div class="col-sm-8">
					<input id="sn" name="sn" th:field="*{sn}" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">IP：</label>
				<div class="col-sm-8">
					<input id="ip" name="ip" th:field="*{ip}" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">MAC：</label>
				<div class="col-sm-8">
					<input id="mac" name="mac" th:field="*{mac}" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">当前工作状态：</label>
				<div class="col-sm-8">
					<input id="state" name="state" th:field="*{state}" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">	
				<label class="col-sm-3 control-label">标注：</label>
				<div class="col-sm-8">
					<input id="remark" name="remark" th:field="*{remark}" class="form-control" type="text">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">服务状态：</label>
				<div class="col-sm-8">
					<div class="onoffswitch">
						<input type="checkbox" th:checked="${wMachine.status == '0' ? true : false}" class="onoffswitch-checkbox" id="status" name="status">
						<label class="onoffswitch-label" for="status">
							<span class="onoffswitch-inner"></span>
							<span class="onoffswitch-switch"></span>
						</label>
					</div>
				</div>
			</div>
		</form>
    </div>
    <div th:include="include::footer"></div>
    <script type="text/javascript">
		var prefix = ctx + "foxwash/wMachine";
		$("#form-wMachine-edit").validate({
			rules:{
				xxxx:{
					required:true,
				},
			}
		});
		
		function submitHandler() {
	        if ($.validate.form()) {
	            //$.operate.save(prefix + "/edit", $('#form-wMachine-edit').serialize());
				edit();
	        }
	    }

        function edit() {
		    var machineId = $("input[name='machineId']").val();
            var shopId = $("#shopId option:selected").val();
            var typeId = $("#typeId option:selected").val();
            var vendorId = $("#vendorId option:selected").val();
            var brand = $("input[name='brand']").val();
            var productDesc = $("input[name='productDesc']").val();
            var imgId = $("input[name='imgId']").val();
            var model = $("input[name='model']").val();
            var sn = $("input[name='sn']").val();
            var name = $("input[name='name']").val();
            var mac = $("input[name='mac']").val();
            var ip = $("input[name='ip']").val();
            var remark = $("input[name='remark']").val();
            var status = $("input[name='status']").is(':checked') == true ? 0 : 1;
            $.ajax({
                cache : true,
                type : "POST",
                url : prefix + "/edit",
                data : {
                    "machineId": machineId,
                    "shopId": shopId,
                    "typeId": typeId,
                    "vendorId": vendorId,
                    "brand": brand,
                    "productDesc": productDesc,
                    "imgId":imgId,
                    "model":model,
                    "sn":sn,
                    "name":name,
                    "mac":mac,
                    "ip":ip,
                    "remark":remark,
                    "status": status
                },
                async : false,
                error : function(request) {
                    $.modal.alertError("系统错误");
                },
                success : function(data) {
                    $.operate.successCallback(data);
                }
            });
        }
	</script>
</body>
</html>
